<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>币种详情</title>
    <link rel="stylesheet" type="text/css" href="../style/api.css" />
    <link rel="stylesheet" type="text/css" href="../style/head.css" />
    <style>
        #closeIt {
            position: absolute;
            top: 35px;
            left: 1rem;
            width: 2rem;
            height: 2rem;
        }

        main {
            padding-top: 75px;
            border-top: 1px solid #ccc;
        }

        .upColor {
            color: #00c087;
        }

        .zeroColor {
            color: #5A92FF;
        }

        .downColor {
            color: #ff7858;
        }

        .coinBox {
            width: 100%;
        }

        main .coinName,
        main .price,
        main .conversion {
            padding: 0.5rem 1rem;
            background-color: #fff;
        }

        .coinName {
            font-size: 1.5rem;
            box-sizing: border-box;
        }

        .coinName img {
            width: 3rem;
            height: 3rem;
            margin-right: 0.3rem;
            vertical-align: middle;
        }

        .coinName span {
            font-size: 1.2rem;
            font-weight: bold;
        }

        .price {
            box-sizing: border-box;
        }

        .price span {
            font-size: 1.8rem;
            margin-right: 0.5rem;
        }

        .conversion {
            font-weight: bold;
            font-size: 1.2rem;
        }

        .conversion span {
            color: #2b4b6b;
            font-style: oblique;
        }

        .conversion span:nth-child(1) {
            margin-right: 2rem;
        }

        .market {
            margin-top: 1rem;
            padding: 1rem;
            box-sizing: border-box;
            background-color: #fff;
        }

        .market .title {
            font-size: 1.2rem;
            font-weight: bold;
        }

        .title img {
            width: 2.5rem;
            height: 2.5rem;
            vertical-align: middle;
        }

        #Klinegraph {
            width: 100%;
            height: 300px;
            border-bottom: 2px solid #f2f2f2;
        }

        .introduce {
            margin-top: 1rem;
        }

        .introduce h3:before {
            content: "";
            display: inline-block;
            width: 4px;
            height: 16px;
            margin-right: 8px;
            background: #007aff;
            vertical-align: -1px;
            border-radius: 3px;
        }

        .content {
            margin-top: 0.5rem;
            padding: 0.5rem;
            box-sizing: border-box;
            color: #666;
            background-color: #F1FAFA;
        }

        .content p {
            margin: 0.5rem;
            line-height: 1.3;
            letter-spacing: .2;
        }
    </style>
</head>

<body>
    <header>
        币种详情
        <img src="../img/icons/back.png" alt="" onclick="api.closeWin()" id="closeIt">
    </header>
    <main>
        <div class="coinBox">

        </div>

        <div class="market">
            <div class="title">
                <img src="../img/icons/market.png" alt=""> 市场走势
            </div>
            <div id="Klinegraph">

            </div>
            <div class="introduceBox">

            </div>
        </div>
    </main>
</body>
<script type="text/template" id="coinDetail">
    {{~it.items:value:index}}
    <div class="coinName">
        <img src="{{=value.coin_logo}}" alt="">
        <span>{{=value.coin_name}}</span>
    </div>
    {{? value.coin_upordown.charAt(0) == '+' && value.coin_upordown != '+0.0%'}}
    <div class="price upColor">
        ￥<span>{{=value.coin_price}}</span> -￥{{=value.coin_currentmarket}} ({{=value.coin_upordown}}) ↑
    </div>
    {{?? value.coin_upordown.charAt(0) == '-'}}
    <div class="price downColor">
        ￥<span>{{=value.coin_price}}</span> -￥{{=value.coin_currentmarket}} ({{=value.coin_upordown}}) ↓
    </div>
    {{?? value.coin_upordown == '+0.0%'}}
    <div class="price zeroColor">
        ￥<span>{{=value.coin_price}}</span> -￥{{=value.coin_currentmarket}} ({{=value.coin_upordown}}) ——
    </div>
    {{?}}
    <div class="conversion">
        <span>≈${{=value.coin_dollar}}</span><span> ≈{{=value.coin_btc}}BTC</span>
    </div>
    {{~}}
</script>
<script type="text/template" id="introduce">
    {{~it.items:value:index}}
    <h3>关于币种 ({{=value.coin_name}})</h3>
    <div class="content">{{=value.coin_introduce}}</div>
    {{~}}
</script>
<script type="text/javascript" src="../js/api.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/doT.min.js"></script>
<script type="text/javascript" src="../js/rend.js"></script>
<script type="text/javascript" src="../js/echarts.min.js"></script>
<script type="text/javascript">
    apiready = function() {
        getCoinInfo();
    };

    function getCoinInfo() {
        api.ajax({
            url: 'http://114.116.243.15/newbtb/appinfo/coininfo.lecture',
            method: 'post',
            data: {
                body: {
                  'tbname': 'lecture_coin',
                  'id': api.pageParam.id
                }
            }
        },function(ret, err){
            if (ret) {
                if (ret.status == 1) {
                    
                    var myChart = echarts.init(document.getElementById('Klinegraph'));
                    var option = {
                        title: {
                            text: "趋势"
                        },
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'cross',
                                label: {
                                    backgroundColor: '#6a7985'
                                }
                            }
                        },
                        legend: {
                            data: ['价格']
                        },
                        grid: {
                            left: '3%',
                            right: '4%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            boundaryGap: false,
                            data: ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
                        },
                        yAxis: [{
                            type: 'value'
                        }],
                        series: [{
                            name: '价格',
                            type: 'line',
                            data: ret.data.coin_movements.split(',')
                        }]
                    };
                    myChart.setOption(option);
                    $('.coinBox').append(btbRender('coinDetail', [ret.data]));
                    $('.introduceBox').append(btbRender('introduce',[ret.data]));
                }
            }
        });
    }
</script>

</html>
